﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Runtime.CompilerServices;

namespace Hands.LoginControl
{
    internal class UriBranchQuery : IQuery
    {
        private static Regex rootRegex = null;

        static UriBranchQuery()
        {
            ConfigFileReader.readConfigToStorage();
        }

        internal static void addRootRegex(Regex rootRegex)
        {
            UriBranchQuery.rootRegex = rootRegex;
        }

        #region IQuery 成员

        [MethodImpl(MethodImplOptions.Synchronized)]
        public UriBranch find(string path)
        {
            string rootPath = rootRegex.Match(path).Value;
            return ConfigStorage.getRoot(rootPath);
        }

        #endregion
    }
}
